<?php 

function SearchFilter($query) {
    if ($query->is_search) {
        $query->set('post_type', 'post');
    }
    return $query;
}
 
add_filter('pre_get_posts','SearchFilter');

// WP 3.0 custom background compatibility 
add_custom_background();

/// WP 3.0 menus compatibility
register_nav_menus( array(
		'primary' => __( 'Primary Navigation' ),
	) );

function new_nav_menu_items($items) {
    $homelink = '<li class="home"><a href="' . home_url( '/' ) . '">' . __('Home') . '</a></li>';
    $items = $homelink . $items;
    return $items;
}

add_filter('wp_nav_menu_items','new_nav_menu_items');
add_filter('wp_list_pages','new_nav_menu_items');


if ( function_exists('register_sidebar') ) 
{     
register_sidebar(array('name' => 'Sidebar Top','before_widget' => '<div class="sidebar-background">','after_widget' => '</div>','before_title' => '<h3>','after_title' => '</h3>'));      
register_sidebar(array('name' => 'Sidebar Left','before_widget' => '','after_widget' => '','before_title' => '<h3>','after_title' => '</h3>')); 
register_sidebar(array('name' => 'Sidebar Right','before_widget' => '','after_widget' => '','before_title' => '<h3>','after_title' => '</h3>'));   
register_sidebar(array('name' => 'Sidebar Bottom','before_widget' => '<div class="sidebar-background">','after_widget' => '</div>','before_title' => '<h3>','after_title' => '</h3>'));        
register_sidebar(array('name' => 'Footer Left','before_widget' => '','after_widget' => '','before_title' => '<h3>','after_title' => '</h3>'));     
register_sidebar(array('name' => 'Footer Center','before_widget' => '','after_widget' => '','before_title' => '<h3>','after_title' => '</h3>'));     
register_sidebar(array('name' => 'Footer Right','before_widget' => '','after_widget' => '','before_title' => '<h3>','after_title' => '</h3>')); 
} 


remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'custom_trim_excerpt');

remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'custom_trim_excerpt');

function custom_trim_excerpt($text) { // Fakes an excerpt if needed
global $post;
	if ( '' == $text ) {
		$text = get_the_content('');

		$text = strip_shortcodes( $text );

		$text = apply_filters('the_content', $text);
		$text = str_replace(']]>', ']]&gt;', $text);
		$text = strip_tags($text);
		$excerpt_length = apply_filters('excerpt_length', 90);
		$words = explode(' ', $text, $excerpt_length + 1);
		if (count($words) > $excerpt_length) {
			array_pop($words);
			array_push($words, '...');
			$text = implode(' ', $words);
		}
	}
	return $text;
}

// WP 3.0 post thumbnails compatibility
if ( function_exists( 'add_theme_support' ) ) { // Added in 2.9
	add_theme_support( 'post-thumbnails' );
	
	add_image_size( 'headline', 300, 275, true ); // Permalink thumbnail size
	add_image_size( 'featured', 100, 65, true );
	add_image_size( 'front-list', 150, 150, true );
}

if ( ! function_exists( 'arthemia_comment' ) ) :
/**
 * Template for comments and pingbacks.
 *
 * To override this walker in a child theme without modifying the comments template
 * simply create your own twentyten_comment(), and that function will be used instead.
 *
 * Used as a callback by wp_list_comments() for displaying the comments.
 *
 * @since Twenty Ten 1.0
 */
function arthemia_comment( $comment, $args, $depth ) {
	$GLOBALS['comment'] = $comment;

	?>
	<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
		<div id="comment-<?php comment_ID(); ?>">
        <div class="clearfloat">

		<?php echo get_avatar( $comment, $size = '55' ); ?>
	

			<div class="commenttext">
			<cite><strong><?php comment_author_link() ?> <?php if($isByAuthor ) { echo '(author)';} ?> </strong> said: </cite>

			<?php if ($comment->comment_approved == '0') : ?>
			<em>Your comment is awaiting moderation.</em>
			<?php endif; ?>
			<?php comment_text() ?>
			</div>	
		</div>
        
		<div class="commentmetadata">
            <div class="reply">
                <?php comment_reply_link( array_merge( $args, array('reply_text'=>__('Reply to this comment &raquo;','arthemia'), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
            </div><!-- .reply -->
        # <?php comment_date('j F Y') ?> at <?php comment_time() ?> 
        </div>

	</div><!-- #comment-##  -->

	<?php
}
endif;

?>